package com.fly.common.util;

import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @description MD5加密
 * @author: fly
 * @date: 2018/11/27 15:36
 */
public class MD5Encoder implements PasswordEncoder {

    @Override
    public String encode(CharSequence rawPassword) {
        return MD5Util.encryptPasswordTwice(rawPassword.toString());
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        String encryptPassword = MD5Util.encryptPasswordTwice(rawPassword.toString());
        return encodedPassword.equals(encryptPassword);
    }
}
